package com.example.demo.config.logconfig;

import java.net.InetAddress;

import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;

public class IpConverter extends ClassicConverter
{
    
    /**
     * 业务系统机器的IP
     */
    private static String hostIp = "";
    
    static
    {
        InetAddress ia = null;
        try
        {
            ia = InetAddress.getLocalHost();
            hostIp = ia.getHostAddress();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
    
    @Override
    public String convert(ILoggingEvent event)
    {
        return new StringBuilder("SERVERIP:" + hostIp).toString();
    }
}
